package com.mjfeed.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

/**
 * @description 支付方式
 * @author zhaominglei
 * @date 2014年10月9日
 */
@Entity
@Table(name="feed_payment_method")
public class PaymentMethod extends OrderEntity {
	private static final long serialVersionUID = -1298473892027178195L;
	
	/** 名称 */
	private String name;

	/** 
	 * 方式 
	 * 0 在线支付 1 线下支付
	 */
	private Integer method;

	/** 超时时间 */
	private Integer timeout;

	/** 图标 */
	private String icon;

	/** 描述 */
	private String description;

	/** 内容 */
	private String content;

	/** 支持配送方式 */
	private Set<ShippingMethod> shippingMethods = new HashSet<ShippingMethod>();

	/** 订单 */
	private Set<Order> orderSet = new HashSet<Order>();

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getMethod() {
		return method;
	}

	public void setMethod(Integer method) {
		this.method = method;
	}

	public Integer getTimeout() {
		return timeout;
	}

	public void setTimeout(Integer timeout) {
		this.timeout = timeout;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(columnDefinition="LONGTEXT")
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@ManyToMany(fetch=FetchType.LAZY)
	@JoinTable(name="feed_payment_shipping_method", joinColumns={@JoinColumn(name="payment_method_id", updatable=false)}, inverseJoinColumns={@JoinColumn(name="shipping_method_id", updatable=false)})
	@OrderBy("orders asc")
	public Set<ShippingMethod> getShippingMethods() {
		return shippingMethods;
	}

	public void setShippingMethods(Set<ShippingMethod> shippingMethods) {
		this.shippingMethods = shippingMethods;
	}

	@OneToMany(mappedBy="paymentMethod", fetch=FetchType.LAZY)
	public Set<Order> getOrderSet() {
		return orderSet;
	}

	public void setOrderSet(Set<Order> orderSet) {
		this.orderSet = orderSet;
	}
}
